package com.ifengchao.dao.impl;

import com.ifengchao.commonUtil.DaoException;
import com.ifengchao.dao.IBatisBaseDao1;
import com.ifengchao.dao.IBatisBaseDao2;
import com.ifengchao.dao.iface.DealPlatformDao;
import com.ifengchao.pojo.PlatformInfo;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 平台处理dao
 *
 * @author HuangYL
 */
@Repository
public class DealPlatformDaoImpl implements DealPlatformDao {

    private static final Logger logger = Logger.getLogger(DealPlatformDaoImpl.class);

    @Autowired(required = true)
    private IBatisBaseDao1 iBatisBaseDao1;

    @Autowired(required = true)
    private IBatisBaseDao2 iBatisBaseDao2;

    /**
     * 查询所有平台
     */
    @Override
    public List<PlatformInfo> queryAllPlatform() throws DaoException {
        logger.info("查询所有平台");
        List<PlatformInfo> list = iBatisBaseDao1.getSqlMapClientTemplate().queryForList("dealPlatformSql.queryAllPlatform");
        return list;
    }

    @Override
    public void insertPlatformInfo(PlatformInfo entity) throws DaoException {
        logger.info("添加平台");
        iBatisBaseDao1.getSqlMapClientTemplate().insert("dealPlatformSql.insertPlatform", entity);
    }

    @Override
    public int updatePlatformInfo(PlatformInfo entity) throws DaoException {
        logger.info("更新平台");
        return iBatisBaseDao1.getSqlMapClientTemplate().update("dealPlatformSql.updatePlatform", entity);
    }
}
